<?php
    include_once('session_clientes.php');
    
    //viene a modificar?
    if(isset($_GET['i'])){
        require_once('php/class/detalles_pedidos.class.php');
        $oDetalle_pedido = new detalle_pedido();
        $id_pedido = $_GET['i'];
        $el_detalle = $oDetalle_pedido->detallar_pedido($id_pedido,3);
		
			if($el_detalle==0){
					echo "Ha ocurrido un error, lo sentimos";
					exit();
				}
		$tabla = "<table class='formulario' width='100%'>
					<tr>
						<th>n</th>
						<th>Marca</th>
						<th>Art&iacute;culo</th>
						<th>Precio</th>
						<th>Cantidad</th>
					</tr>";
		
		$total = 0;
		$cantidad = 0;
		$total_articulo = 0;
		$m = 1;			
		for($i=0;$i<count($el_detalle['ID']);$i++){
			$tabla .= "<tr>";
			$tabla .= "<td align='CENTER'>".$m++."</td>";
			$tabla .= "<td align='CENTER'>".$el_detalle['MARCA'][$i]."</td>";
			$tabla .= "<td align='CENTER'>".$el_detalle['NOMBRE'][$i]."</td>";
			$tabla .= "<td align='CENTER'>$".$el_detalle['PRECIO_UNITARIO'][$i]."</td>";
			$tabla .= "<td align='CENTER'>".$el_detalle['CANTIDAD'][$i]."</td>";
			$tabla .= "</tr>";
			
			$total_articulo = $el_detalle['PRECIO_UNITARIO'][$i] * $el_detalle['CANTIDAD'][$i];
			
			$total = $total + $total_articulo;
			}
	
		$tabla .= "<tr height='50px'><td colspan='6'></td></tr>";
		$tabla .= "<tr><td colspan='6' align='right'>Total: $".$total."</td></tr>";
        $tabla .= "</table>";
    }else{
        
        exit();
    }
    
?>
<html>
    
    <body>
    <?php echo $tabla;?>
    </body>
</html>
